package com.example.app2.controller;

import com.example.common.core.Result;
import com.example.common.entity.DemoEntity;
import com.example.feign.app1.App1HelloClient;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    private App1HelloClient app1HelloClient;

    @GetMapping("/feign1")
    public Result<Object> feign1() {
        System.out.println(app1HelloClient.feign1(LocalDate.now()));
        return Result.success();
    }

    @GetMapping("/feign2")
    public Result<Object> feign2() {
        DemoEntity bean = new DemoEntity();
        bean.setDatetime(LocalDateTime.now());
        bean.setDate(LocalDate.now());
        bean.setTime(LocalTime.now());
        System.out.println(app1HelloClient.feign2(bean));
        return Result.success();
    }

    @GetMapping("/feign3")
    public Result<Object> feign3() {
        DemoEntity bean = new DemoEntity();
        bean.setDatetime(LocalDateTime.now());
        bean.setDate(LocalDate.now());
        bean.setTime(LocalTime.now());
        System.out.println(app1HelloClient.feign3("test", bean));
        return Result.success();
    }
}
